#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<stdio.h>
#include<unistd.h>
/*
	success fd = 3
	ret=-1
 */
int main(){
	int fd = open("test.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666);
	if(fd < 0){
		perror("open file");
		return 0;
	}
	printf("success fd = %d\n", fd);

	//关闭文件
	int ret = close(fd);
	if(ret < 0){
		perror("close failed");
	}

	//做个测试，再关闭一次，此时返回的是-1
	ret = close(fd);
	printf("ret=%d\n", ret);
}

